<template>
  <div class="addchufang">
    处方单
    <div class="clearfix ">
      <div width="30%" class="flowL chufangInput">
        <label style="display: inline-block">就诊医生id：</label>
        <el-select
          v-model="value"
          class="doctorid"
          placeholder="请选择"
          @change="filterData()"
        >
          <el-option
            v-for="item in options"
            :key="item.doctorNo"
            :label="item.doctorNo"
            :value="item.doctorNo"
          >
          </el-option>
        </el-select>
        <br /><br />
        <div class="flowL">
          医生姓名: <span class="docteorname"></span>
          {{ Doctor[0].doctorName }}
        </div>
        <div class="flowL chufangInput">|</div>
        <div class="flowL">
          科室：<span class="SubjectName">{{ Doctor[0].subjectName }}</span>
        </div>
      </div>
      <div
        class="flowL"
        style="width: 400px;padding:0px 10px;border-left: 1px solid;"
      >
        <div>病人姓名：{{ patientInfo.name }}</div>
        <div>
          性别：
          <el-radio-group v-model="thissex">
            <el-radio label="男"></el-radio>
            <el-radio label="女"></el-radio>
          </el-radio-group>
        </div>
        <div class="clearfix ">
          <span class="flowL">年龄： </span>
          <div class="flowL" style="width:100px">
            <el-input
              placeholder="年龄"
              v-model="thisage"
              @input="reg()"
              type="number"
            ></el-input>
          </div>
        </div>
      </div>
    </div>

    <br />
    <div class="clearfix">
      <div class="flowR chufangInput" id="liushui">
        流水号:
        <span class="chufangnum">{{ Pres_number }}</span
        >
      </div>
    </div>
  </div>
</template>
<script>
import { mapActions, mapMutations, mapGetters } from "vuex";
export default {
  props: ["patientInfo"],
  data() {
    return {
      options: [],
      isseleced: {},
      value: "",
      obj: {
        doctorNo: null
        // person_no: '099'
      },
      Doctor: [
        {
          doctorNo: "输入医生id",
          doctorName: "",
          subjectNo: "",
          subjectName: "",
          subjectNol: "",
          personNo: "",
          isDeleted: ""
        }
      ],
      Pres_number: null,
      thissex: "",
      thisage: ""
    };
  },
  created() {
    this.Pres_number = new Date().valueOf();
    this.getalldoctor();
  },
  watch: {
    thissex() {
      console.log(this.thissex);
      this.$emit("sex", this.thissex);
    },
    thisage() {
      this.$emit("age", this.thisage);
    }
  },
  methods: {
    ...mapActions(["tongyong"]),

    reg() {
      const reg = /^100$|^(\d|[1-9]\d)$/;
      if (reg.test(this.thisage)) {
        return
      } else {
        this.thisage=0
      }
    },

    getalldoctor() {
      this["tongyong"]({
        name: "GET_ALLDOCTOR",
        data: {
          page: "1",
          pageSize: "999"
        }
      }).then(res => {
        this.options = res.data.data;
        console.log(this.options);
      });
    },
    // 过滤器
    filterData() {
      console.log(this.obj);
      this.obj.doctorNo = this.value;
      this.Doctor = this.options.filter(item => {
        return Object.entries(this.obj).every(([_key, _val]) => {
          if (item[_key] === _val) return true;
        });
      });
    }
  }
};
</script>

<style scoped>
.chufangInput {
  margin: 0 10px;
}

.addchufang {
  /* width: 100%; */
  padding: 5px;
  min-height: 60px;
  background: #d3f3f2;
}
</style>
